package com.tpu.osu.rating.web.pages;

import org.apache.tapestry.annotations.InjectPage;
import org.apache.tapestry.annotations.Service;
import org.apache.tapestry.ioc.annotations.Inject;
import org.apache.tapestry.ioc.annotations.Value;

import com.tpu.osu.rating.Vote;
import com.tpu.osu.rating.service.VoteService;



public class Start {

	@InjectPage
	private Error errorPage;

	@InjectPage
	private Ok okPage;
	
	@Inject
	@Service("voteService")
	private VoteService voteService;

	private int statementRating;
	private int explanationRating;
	private int allocates_mainRating;
	private int calling_interestRating;
	private int watches_reactionRating;
	private int discussionRating;
	private int logicalityRating;
	private int standard_speechRating;
	private int relaxationRating;
	private int orientationRating;
	private int creativityRating;
	private int goodwillRating;
	private int patienceRating;
	private int insistenceRating;
	private int interestRating;
	private int objectivityRating;
	private int respectfulnessRating;
	private int arrangementRating; 
	private String lector;
	private String comments;
	private String pin;

	
	
	
	public Error getErrorPage() {
		return errorPage;
	}
	public void setErrorPage(Error errorPage) {
		this.errorPage = errorPage;
	}
	public Ok getOkPage() {
		return okPage;
	}
	public void setOkPage(Ok okPage) {
		this.okPage = okPage;
	}
	public VoteService getVoteService() {
		return voteService;
	}
	public void setVoteService(VoteService voteService) {
		this.voteService = voteService;
	}
	public int getStatementRating() {
		return statementRating;
	}
	public void setStatementRating(int statement) {
		this.statementRating = statement;
	}
	public int getExplanationRating() {
		return explanationRating;
	}
	public void setExplanationRating(int explanationRating) {
		this.explanationRating = explanationRating;
	}
	public int getAllocates_mainRating() {
		return allocates_mainRating;
	}
	public void setAllocates_mainRating(int allocates_mainRating) {
		this.allocates_mainRating = allocates_mainRating;
	}
	public int getCalling_interestRating() {
		return calling_interestRating;
	}
	public void setCalling_interestRating(int calling_interestRating) {
		this.calling_interestRating = calling_interestRating;
	}
	public int getWatches_reactionRating() {
		return watches_reactionRating;
	}
	public void setWatches_reactionRating(int watches_reactionRating) {
		this.watches_reactionRating = watches_reactionRating;
	}
	public int getDiscussionRating() {
		return discussionRating;
	}
	public void setDiscussionRating(int discussionRating) {
		this.discussionRating = discussionRating;
	}
	public int getLogicalityRating() {
		return logicalityRating;
	}
	public void setLogicalityRating(int logicalityRating) {
		this.logicalityRating = logicalityRating;
	}
	public int getStandard_speechRating() {
		return standard_speechRating;
	}
	public void setStandard_speechRating(int standard_speechRating) {
		this.standard_speechRating = standard_speechRating;
	}
	public int getRelaxationRating() {
		return relaxationRating;
	}
	public void setRelaxationRating(int relaxationRating) {
		this.relaxationRating = relaxationRating;
	}
	public int getOrientationRating() {
		return orientationRating;
	}
	public void setOrientationRating(int orientationRating) {
		this.orientationRating = orientationRating;
	}
	public int getCreativityRating() {
		return creativityRating;
	}
	public void setCreativityRating(int creativityRating) {
		this.creativityRating = creativityRating;
	}
	public int getGoodwillRating() {
		return goodwillRating;
	}
	public void setGoodwillRating(int goodwillRating) {
		this.goodwillRating = goodwillRating;
	}
	public int getPatienceRating() {
		return patienceRating;
	}
	public void setPatienceRating(int patienceRating) {
		this.patienceRating = patienceRating;
	}
	public int getInsistenceRating() {
		return insistenceRating;
	}
	public void setInsistenceRating(int insistenceRating) {
		this.insistenceRating = insistenceRating;
	}
	public int getInterestRating() {
		return interestRating;
	}
	public void setInterestRating(int interestRating) {
		this.interestRating = interestRating;
	}
	public int getObjectivityRating() {
		return objectivityRating;
	}
	public void setObjectivityRating(int objectivityRating) {
		this.objectivityRating = objectivityRating;
	}
	public int getRespectfulnessRating() {
		return respectfulnessRating;
	}
	public void setRespectfulnessRating(int respectfulnessRating) {
		this.respectfulnessRating = respectfulnessRating;
	}
	public int getArrangementRating() {
		return arrangementRating;
	}
	public void setArrangementRating(int arrangementRating) {
		this.arrangementRating = arrangementRating;
	}
	public String getLector() {
		return lector;
	}
	public void setLector(String aLector) {
		lector = aLector;
	}
	public String getComments() {
		return comments;
	}
	public void setComments(String aComments) {
		comments = aComments;
	}
	public String getPin() {
		return pin;
	}
	public void setPin(String aPin) {
		pin = aPin;
	}
	
	
	
	public Object onSuccess() {
		Object result;
		try {
			
			Vote vote = new Vote();
			vote.setComments(comments);
			vote.setAllocates_main(allocates_mainRating);
			vote.setArrangement(arrangementRating);
			vote.setCalling_interest(calling_interestRating);
			vote.setCreativity(creativityRating);
			vote.setDiscussion(discussionRating);
			vote.setExplanation(explanationRating);
			vote.setGoodwill(goodwillRating);
			vote.setInsistence(insistenceRating);
			vote.setInterest(interestRating);
			vote.setLogicality(logicalityRating);
			vote.setObjectivity(objectivityRating);
			vote.setOrientation(orientationRating);
			vote.setPatience(patienceRating);
			vote.setRelaxation(relaxationRating);
			vote.setRespectfulness(respectfulnessRating);
			vote.setStandard_speech(standard_speechRating);
			vote.setStatement(statementRating);
			vote.setWatches_reaction(watches_reactionRating);
			vote.setLector(lector);
			vote.setPin(pin);
			
			voteService.create(vote);
			
			result = okPage;
		} catch (Throwable t){
			errorPage.setErrorMessage(t.getMessage());
			result = errorPage;
		}
		return result;
	}
	
}
